<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
    <div id="test"  tabindex="0">加油加油</div>
    <div id="testShadow"></div>

    <script>


        document.getElementById('test').addEventListener('blur', function(){
            document.getElementById('test').style.backgroundColor = 'red'
        })

        document.getElementById('test').addEventListener('focus', function(){
            document.getElementById('test').style.backgroundColor = 'blue'
        })


        let ele = document.createElement('div')
        ele.setAttribute('id', 'shadowDom')
        ele.innerText = 1111
        ele.setAttribute('tabindex', '0')
        let testShadow = document.getElementById('testShadow').attachShadow({mode:'open'})
        testShadow.append(ele)
        testShadow.getElementById('shadowDom').addEventListener('blur', function(){
            testShadow.getElementById('shadowDom').style.backgroundColor = 'yellow'
        })
        testShadow.getElementById('shadowDom').addEventListener('focus', function(){
            testShadow.getElementById('shadowDom').style.backgroundColor = 'green'
        })
        
       

    </script>
</body>
</html>